{extend name="Public:base"/}

{block name="main"}
<div class="box-info">
    <div class="table-toolbar">
        <div class="row">
            <div class="col-md-12">
                <a class="btn btn-primary" href="{:U('Link/add')}">新增</a>
                <button class="btn btn-primary" onclick="return confirm_deleteall()">删除</button>
                <button class="btn btn-primary" onclick="myform.action='{:U('Link/listorder')}';$('#myform').submit();">排序
                </button>
            </div>
        </div>
    </div>

    <div class="row table-container">
        <div class="col-md-12">
            <form name="myform" id="myform" method="post">
                <table class="table table-hover table-bordered">
                    <thead>
                    <tr>
                        <th width="20"><input type="checkbox" value="" id="check_box" onclick="selectall('ids[]');"></th>
                        <th class="table-cell-1">排序</th>
                        <th width="40">ID</th>
                        <th>名称</th>
                        <th>网站地址</th>
                        <th>logo</th>
                        <th class="table-cell-3">添加时间</th>
                        <th class="table-cell-2 center">管理操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {empty name="list"}
                    <tr class="table-data-empty">
                        <td class="text-center empty-info" colspan="8">
                            <i class="fa fa-database"></i> 暂无数据<br>
                        </td>
                    </tr>
                    {else/}
                    {volist name="list" id="vo" key="k"}
                    <tr>
                        <td width="20" align="center">
                            <input class="inputcheckbox" name="ids[]" value="{$vo['id']}" type="checkbox">
                        </td>
                        <td width="30">
                            <input name='listorders[{$vo.id}]' type='text' size='3' value='{$vo.listorder}' class="form-control input-c">
                        </td>
                        <td>{$vo['id']}<input class="id" type="hidden" name="id" value="{$vo['id']}"></td>
                        <td>{$vo['name']}</td>
                        <td>{$vo['siteurl']}</td>
                        <td>
                            {if condition="$vo['weblogo']"}
                            <img src="{$vo['weblogo']}" height=26>
                            {/if}
                        </td>
                        <td align="center">{$vo['create_time']|todate="Y-m-d H:i:s"}</td>
                        <td class="table-cell-2 center">
                            <a class="btn btn-sm btn-primary" href="{:U('Link/edit',array('id'=>$vo['id']))}">编辑</a>
                            <a class="btn btn-sm btn-danger"
                               href="javascript:confirm_delete('{:U('Link/delete',array(id=>$vo['id']))}')">删除</a>
                        </td>
                    </tr>
                    {/volist}
                    {/empty}
                    </tbody>
                </table>
            </form>
        </div>
    </div>
    <div class="pagination">{$page}</div>
</div>
<script>
    // 确认删除
    function confirm_deleteall() {
        var str = 0;
        var id = tag = '';
        $('input[name="ids[]"]:checked').each(function () {
            str = 1;
            id += tag + $(this).val();
            tag = ',';
        });
        if (str == 0) {
            layer.msg('您没有勾选信息，无法进行操作！', {
                icon: 2,
                time: 1000 //2秒关闭（如果不配置，默认是3秒）
            });
            return false;
        }
        layer.confirm("确认要删除信息吗?", function () {
            myform.action = '/?g=admin&m=Link&a=delete&id=' + id;
            $('#myform').submit();
        });
    }
</script>
{/block}